#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>


int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    int cnt = 5;
    while(cnt)
    {
      printf("i am child process,pid:%d ,ppid:%d\n",getpid(),getppid());
      sleep(1);
      cnt--;
    }
    exit(111);

  }
  sleep(10);
  int status = 0;
  pid_t rid =waitpid(id,&status,0);
  if(WIFEXITED(status)){
  printf("wait success! rid:%d , status:%d,exit code:%d\n",rid,status,WEXITSTATUS(status));}
//  if(rid>0){
//  printf("wait success! rid:%d , status:%d,exit singno:%d, exit code:%d\n",rid,status,status&0x7F,(status>>8)&0xFF);
//  }
//
  return 0;
}
